﻿using UnityEngine;
using System.Collections.Generic;

/// <summary>
/// Xcode项目的一些设定值
/// </summary>
public class XCodeProjectConfig 
{
    public const string PROJECT_ROOT = "$(PROJECT_DIR)/";
    public const string IMAGE_XCASSETS_DIRECTORY_NAME = "Unity-iPhone";

    public const string LINKER_FLAG_KEY = "OTHER_LDFLAGS";

    public const string FRAMEWORK_SEARCH_PATHS_KEY = "FRAMEWORK_SEARCH_PATHS";
    public const string LIBRARY_SEARCH_PATHS_KEY = "LIBRARY_SEARCH_PATHS";

    public const string INFO_PLIST_NAME = "Info.plist";

    public const string ChannelConfigFodlerEx = "Editor/IOSPorter/ChannelConfig";
    public const string ChannelConfigFodler = "Assets/Editor/IOSPorter/ChannelConfig";

    #region XCodeproj

    public string InfoPlistConfigPath = "Assets/Editor/IOSPorter/ChannelConfig/opensdk_ali";
    //要拷贝到XCode内的文件的路径
    public string CopyDirectoryPath = "Assets/Editor/IOSPorter/ChanelResources/opensdk_ali/CommonResources";

    #region SetBuildProperty 系统构建属性 [key;value]
    //SetBuildProperty（target ， Description ， value） --- buildconfig
    public List<string> SetBuildProperty = new List<string>()
    {
        //设置签名
        "CODE_SIGN_IDENTITY;iPhone Developer:证书名", //CODE_SIGN_IDENTITY = iPhone Developer: 人甲 路 (XXXXXXXXXX)，其中证书的名称可以在 Keychain Access 里面找到
        "PROVISIONING_PROFILE_SPECIFIER;xxxxx:xxxxx", //指定证书名
        "CODE_SIGN_ENTITLEMENTS;KeychainAccessGroups.plist",
        "DEVELOPMENT_TEAM;xxxxxxxxxx",  //AppleDevelopment内AppID表示

        //
        "IPHONEOS_DEPLOYMENT_TARGET;9.0",
        "GCC_OPTIMIZATION_LEVEL;9.0",

        //编译配置
        "ENABLE_BITCODE;NO",
        "GCC_ENABLE_CPP_EXCEPTIONS;YES",
        "GCC_ENABLE_CPP_RTTI;YES",
        "GCC_ENABLE_OBJC_EXCEPTIONS;YES",

        //添加路径索引
        /*
         *外部依赖库需要添加到BuildSettings(Frameworked Search path)  other framework 库添加如此(Umeng framework)
            sreach path 路径 以库工程路径和主工程相对路径编写，文件路径有变更后sreach path 路径也需要变更 .
            一般Copy的文件过程中对于path 也直接自动添加
         *工程头文件搜索路径(HEADER_SEARCH_PATHS_KEY)
         *工程Lib搜索路径(LIBRARY_SEARCH_PATHS_KEY)
         * 都可以以 .AddBuildProperty(target,key,value)的方式添加
         * [HEADER_SEARCH_PATHS_KEY;$(SRCROOT)/../File]
         * [LIBRARY_SEARCH_PATHS_KEY;$(SRCROOT)/../Lib]
         * 
         * LINKER_FLAG_KEY , 
         * 
         * 也可以通过 .AddFileToBuild() 方式 或者 .UpdateBuildProperty(target,key,addValues,removeValues);
         */
        "FRAMEWORK_SEARCH_PATHS_KEY;$(inherited)",
        "FRAMEWORK_SEARCH_PATHS_KEY;$(PROJECT_DIR)/Frameworks",  
    };
    #endregion

    #region SetSystemCapabilites
    public List<string> SetSystemCapabilites = new List<string>() //background mode ???
    {
         "com.apple.Push;1",
         "com.apple.GameCenter;1",
         "com.apple.InAppPurchase;1",
         "com.apple.BackgroundModes;1"
    };

    #endregion

    #region AddFramework & .tdb
    //引用的内部Framework //引用的内部.tbd
    public List<string> FrameworkList = new List<string>()
    {
        "CoreAudio.framework",
        "MobileCoreServices.framework",
        "Security.framework",
        "ImageIO.framework",
        "StoreKit.framework",
        "UIKit.framework",
        "UserNotifications.framework:optional",
        "CoreFoundation.framework",
        "CoreTelephony.framework",
        "AdSupport.framework",
        "CoreText.framework",
        "AudioToolbox.framework",
        "AVFoundation.framework:optional",
        "SafariServices.framework:optional",
        "libstdc++.6.0.9.tbd",
        "libresolv.tbd",
        "libstdc++.tbd",
        "libsqlite3.tbd",
        "libz.tbd",
    };
    #endregion

    #region AddFileToBuild
    //.tbd文件直接AddFramework Xcode会添加不进去 ，通过AddFileToBuild 是可以的
    // AddFile 添加文件到XCode 目录 ，返回文件 GUID
    //AddFileToBuild 是将GUID 文件添加到XCode BuildPhases 阶段
    public List<string> AddFileToBuild = new List<string>()
    {
        //path;path
    };

    #endregion

    #region LinkerFlagArray
    //设置.UpdateBuildProperty(target,key,addValues,removeValues);
    public string[] LinkerFlagArray = new string[] { };
    #endregion

    #region Add Keychain
    //Application.dataPath + "你的目录/KeychainAccessGroups.plist", "KeychainAccessGroups.plist")
    public string keychainPath;

    #endregion

    #region 针对单个文件进行flag标记
    [System.Serializable]
    public struct CompilerFlagsSet
    {
        public string Flags;
        public List<string> TargetPathList;

        public CompilerFlagsSet(string flags, List<string> targetPathList)
        {
            Flags = flags;
            TargetPathList = targetPathList;
        }
    }

    public List<CompilerFlagsSet> CompilerFlagsSetList = new List<CompilerFlagsSet>()
    {
        /*new CompilerFlagsSet ("-fno-objc-arc", new List<string> () {"Plugin/Plugin.mm"})*/ //实例，请勿删除
    };
    #endregion

    #endregion

    #region 拷贝文件
    [System.Serializable]
    public struct CopeFiles
    {
        public string sourcePath;
        public string copyPath;

        public CopeFiles(string sourcePath, string copyPath)
        {
            this.sourcePath = sourcePath;
            this.copyPath = copyPath;
        }
    }

    public List<CopeFiles> CopeFilesList = new List<CopeFiles>() { };
    #endregion
}